package Koneksi;

import oracle.jdbc.pool.OracleDataSource;
import java.sql.*;
import Kasir.*;

public class Koneksi {    
    
    private Connection conn = null;

    public Koneksi() {
        try {
            OracleDataSource ds = new OracleDataSource();
            ds.setURL("jdbc:oracle:thin:@localhost:1521:XE");
            conn = ds.getConnection("HR", "astri");
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
    }

    public boolean bolehLogin(String Password, String Id_Kasir, String status) {
        try {
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("select password,id_kasir from Kasir where "
                    + "password = '" + Password + "' and id_kasir = '" + Id_Kasir + "'");
      
            return rs.next();
        } catch (SQLException ex) {
            return false;
        }               
    }
    
    public Connection getConnection() {
        String jdbcURL = "jdbc:oracle:thin:@localhost:1521:XE";
        String user = "HR";
        String password = "astri";
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            conn = DriverManager.getConnection(jdbcURL, user, password);
            System.out.println("koneksi berhasil");
        } catch (Exception ex) {
            System.out.println("message: " + ex.getMessage());
        }
        return conn;
    }
    
    
    
    public static void main(String[] args) {
        Koneksi koneksi = new Koneksi();
        Loading loading = new Loading(); 
    }
}
    
    